﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace Radiation___IM
{
    public class Hash
    {
        public static string Md5(string data)
        {
            MD5 md5HashAlgo = MD5.Create();
            byte[] hashResult = md5HashAlgo.ComputeHash(Encoding.UTF8.GetBytes(data));
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < hashResult.Length; i++)
                result.Append(hashResult[i].ToString("X2"));
            return result.ToString();
        }
        public static string Sha1(string data)
        {
            SHA1 md5HashAlgo = SHA1.Create();
            byte[] hashResult = md5HashAlgo.ComputeHash(Encoding.UTF8.GetBytes(data));
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < hashResult.Length; i++)
                result.Append(hashResult[i].ToString("X2"));
            return result.ToString();
        }
        public static string Sha256(string data)
        {
            SHA256 md5HashAlgo = SHA256.Create();
            byte[] hashResult = md5HashAlgo.ComputeHash(Encoding.UTF8.GetBytes(data));
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < hashResult.Length; i++)
                result.Append(hashResult[i].ToString("X2"));
            return result.ToString();
        }
        public static string Sha384(string data)
        {
            SHA384 md5HashAlgo = SHA384.Create();
            byte[] hashResult = md5HashAlgo.ComputeHash(Encoding.UTF8.GetBytes(data));
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < hashResult.Length; i++)
                result.Append(hashResult[i].ToString("X2"));
            return result.ToString();
        }
        public static string Sha512(string data)
        {
            SHA512 md5HashAlgo = SHA512.Create();
            byte[] hashResult = md5HashAlgo.ComputeHash(Encoding.UTF8.GetBytes(data));
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < hashResult.Length; i++)
                result.Append(hashResult[i].ToString("X2"));
            return result.ToString();
        }
    }
}
